cmake_minimum_required(VERSION 2.8)
project(test_thread)

set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS} -g")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)

file(GLOB_RECURSE UI_FILES ui/*.ui)
file(GLOB_RECURSE SOURCE_FILES src/*.cpp)
file(GLOB_RECURSE HEADER_FILES include/*.h)

find_package(Qt5Widgets REQUIRED)

find_package(OpenCV REQUIRED)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  sensor_msgs
  cv_bridge
  image_transport
)

catkin_package(
)

qt5_wrap_ui(UI_HEADERS ${UI_FILES})

add_executable(${PROJECT_NAME}
  ${UI_HEADERS}
  ${SOURCE_FILES}
  ${HEADER_FILES}
)

execute_process(
  COMMAND git clone  https://git.oschina.net/sukibean/ThreadObject.git -b nostd_ros_ver
  WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
  )

add_subdirectory(ThreadObject)

include_directories(
	include
  ThreadObject
	${catkin_INCLUDE_DIRS}
)



target_link_libraries(${PROJECT_NAME}
	${catkin_LIBRARIES}
	Qt5::Widgets
	${OpenCV_LIBS}
  ThreadObject
)


add_custom_command(TARGET ${PROJECT_NAME} PRE_BUILD
                   COMMAND rm -rf ThreadObject
                   WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
                   )

